package unit_5;

import java.util.Scanner;

public class Demo05 {
    public static void Mysort(int[] a){
        for(int i = 0; i < a.length; i++){
            int min = i;
            for(int j = i + 1; j < a.length; j++){
                if(a[min] > a[j])
                    min = j;
            }
            int temp = a[i];
            a[i] = a[min];
            a[min] = temp;
        }
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int [8];
        System.out.println("请输入8个整数：");
        for(int i = 0; i < a.length; i++){
            a[i] = sc.nextInt();
        }
        System.out.print("排序前的数组：");
        for(int num : a) {
            System.out.print(num + " ");
        }
        Mysort(a);
        System.out.print("\n排序后的数组：");
        for (int j : a) {
            System.out.print(j + " ");
        }
    }
}
